//
// Created by liushuai on 2021/3/9.
//

#include "GraphNode.h"

<<<<<<< HEAD
GraphNode::GraphNode(string n, priority_queue<int> e, map<int, GraphNode *> etn) : name(n), edge(e),
                                                                                   edge_to_node(std::move(etn)) {
}

GraphNode::GraphNode(string n, vector<int> e, map<int, GraphNode *> etn) : name(n), edge_to_node(etn) {
    setEdge(e);
=======
GraphNode::GraphNode(string n, priority_queue<int> e, map<int, GraphNode *> etn)
    : name(n), edge(e), edge_to_node(std::move(etn)) {}

GraphNode::GraphNode(string n, vector<int> e, map<int, GraphNode *> etn)
    : name(n), edge_to_node(etn) {
  setEdge(e);
>>>>>>> dev
}

GraphNode::GraphNode(string n) : name(n) {}

GraphNode *GraphNode::getMinNode() {
<<<<<<< HEAD
    GraphNode* current= nullptr;
    for(int i=0;i<edge.size();i++){
        current = edge_to_node[-edge.top()];
        if(!current->getVisit())
            break;
        else{
            edge.pop();
        }
    }

    return current;
}

string GraphNode::getName() {
    return name;
}

void GraphNode::setEdgeToNode(map<int, GraphNode *> &e) {
    edge_to_node = e;
}

void GraphNode::setEdge(vector<int> &e) {
    for(auto elem:e){
        edge.push(-elem);
    }
}
GraphNode::GraphNode(string n, vector<int> e) {
    name = n;
    setEdge(e);
}
void GraphNode::setVisited() {
    isVisit = true;
}
bool GraphNode::getVisit() {
    return isVisit;
}
=======
  GraphNode *current = nullptr;
  for (int i = 0; i < edge.size(); i++) {
    current = edge_to_node[-edge.top()];
    if (!current->getVisit())
      break;
    else {
      edge.pop();
    }
  }

  return current;
}

string GraphNode::getName() { return name; }

void GraphNode::setEdgeToNode(map<int, GraphNode *> &e) { edge_to_node = e; }

void GraphNode::setEdge(vector<int> &e) {
  for (auto elem : e) {
    edge.push(-elem);
  }
}
GraphNode::GraphNode(string n, vector<int> e) {
  name = n;
  setEdge(e);
}
void GraphNode::setVisited() { isVisit = true; }
bool GraphNode::getVisit() { return isVisit; }
>>>>>>> dev
